package org.cinvestav.computacion.matias.onlyangel.j3d;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;

import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;


import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.SimpleUniverse;


public class PrimerDibujo extends Applet{
	
	private static final long serialVersionUID = 1L;
	
	public PrimerDibujo(){
		setLayout(new BorderLayout());
		GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
		Canvas3D canvas3D = new Canvas3D(config);
		add("Center",canvas3D);
		BranchGroup escena = createSceneGraph();
		escena.compile();
		SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
		simpleU.getViewingPlatform().setNominalViewingTransform();
		simpleU.addBranchGraph(escena);
	}
	private BranchGroup createSceneGraph() {
		
		BranchGroup objRoot = new BranchGroup();
		
		/*Transform3D rotacion = new Transform3D();
		Transform3D segrotacion = new Transform3D();
		
		rotacion.rotX(Math.PI/4.0d);
		segrotacion.rotY(Math.PI/3.0d);
		
		rotacion.mul(segrotacion);
		
		TransformGroup objrotacion= new TransformGroup(rotacion);
		
		objRoot.addChild(objrotacion);
		*/
		
		objRoot.addChild(new Fondo(17,21,512,256));
		objRoot.addChild(new Robot(0));
		
		return objRoot;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Frame frame = new MainFrame(new PrimerDibujo(),512,256);
	}

}
